package com.hsjk.szwj.module.system.dal.mysql.service;

import java.util.*;

import com.hsjk.szwj.framework.common.pojo.PageResult;
import com.hsjk.szwj.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.hsjk.szwj.framework.mybatis.core.mapper.BaseMapperX;
import com.hsjk.szwj.module.system.dal.dataobject.service.ServiceDO;
import org.apache.ibatis.annotations.Mapper;
import com.hsjk.szwj.module.system.controller.admin.service.vo.*;

/**
 * 服务信息 Mapper
 *
 * @author ec50n9
 */
@Mapper
public interface ServiceMapper extends BaseMapperX<ServiceDO> {

    default PageResult<ServiceDO> selectPage(ServicePageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<ServiceDO>()
                .likeIfPresent(ServiceDO::getServiceName, reqVO.getServiceName())
                .eqIfPresent(ServiceDO::getServiceCode, reqVO.getServiceCode())
                .eqIfPresent(ServiceDO::getServiceType, reqVO.getServiceType())
                .eqIfPresent(ServiceDO::getDescription, reqVO.getDescription())
                .eqIfPresent(ServiceDO::getValidDays, reqVO.getValidDays())
                .eqIfPresent(ServiceDO::getMenuIds, reqVO.getMenuIds())
                .betweenIfPresent(ServiceDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(ServiceDO::getId));
    }

    default List<ServiceDO> selectList(ServiceExportReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<ServiceDO>()
                .likeIfPresent(ServiceDO::getServiceName, reqVO.getServiceName())
                .eqIfPresent(ServiceDO::getServiceCode, reqVO.getServiceCode())
                .eqIfPresent(ServiceDO::getServiceType, reqVO.getServiceType())
                .eqIfPresent(ServiceDO::getDescription, reqVO.getDescription())
                .eqIfPresent(ServiceDO::getValidDays, reqVO.getValidDays())
                .eqIfPresent(ServiceDO::getMenuIds, reqVO.getMenuIds())
                .betweenIfPresent(ServiceDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(ServiceDO::getId));
    }

}
